package com.jiaeda.shiroweb.mapper;

import com.jiaeda.shiroweb.entity.SysRolePermission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by chengchaopeng on 2018/6/27.
 */
@Mapper
@Component
public interface SysRolePermissionMapper {


    /**
     * 根据角色列表获取所对应的权限信息
     * @param roleIds
     * @return
     */
    @Select("<script>select permission_id as permissionId,role_id as roleId from sys_role_permission " +
            "WHERE" +
            "<if test=\"roleIds!=null\">" +
            " role_id in " +
            "<foreach collection='roleIds' index='index' item='item' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</if></script>")
    List<SysRolePermission> findByRoleIds(@Param("roleIds") String[] roleIds);
}
